﻿<my1:RibbonWindow xmlns:my1="clr-namespace:Fluent;assembly=Fluent"  
    xmlns:my="clr-namespace:devtm.Editor.Configuration;assembly=devtm.Editor.Configuration"  
        xmlns:e="clr-namespace:devtm.Editor.Configuration.Messages;assembly=devtm.Editor.Configuration"
        x:Class="ConfigEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:u="clr-namespace:devtm.Editor.Configuration;assembly=devtm.Editor.Configuration"
        xmlns:p="clr-namespace:ConfigEditor"     
        Title="Section Editor" 
                  Icon = "/ConfigEditor;component/Images/Editor.ico"
                  Height="350" Width="719" 
                  Closing="WindowsClosing">
    
    <my1:RibbonWindow.Resources>
        <DataTemplate DataType="{x:Type e:MessageText}" >
            <StackPanel Margin="0,10,0,5" Orientation="Horizontal" HorizontalAlignment="Left">

                <Image Height="24" Width="24" Source="/devtm.Editor.Configuration;component/Images/Info2.png" Margin="10,0,10,0" />

                <Button Grid.Column="1" Content="{Binding Label}" Click="Button_Click_3" Tag="{Binding .}" Margin="2,0,5,0"  Visibility="{Binding Show}" />

                <TextBlock
                       Text="{Binding Message}"
                       FontWeight="Bold"
                       ToolTip="{Binding Description}" TextWrapping="Wrap"  />
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type e:MessageTextError}" >
            <StackPanel Margin="0,10,0,5" Orientation="Horizontal" HorizontalAlignment="Left">

                <Image Height="24" Width="24" Source="/devtm.Editor.Configuration;component/Images/Info2.png" Margin="10,0,10,0" />

                <Button Grid.Column="1" Content="{Binding Label}" Click="Button_Click_3" Tag="{Binding .}" Visibility="{Binding Show}"  Margin="2,0,5,0" />
                
                <TextBlock
                       Text="{Binding Message}"
                       FontWeight="Bold"
                       ToolTip="{Binding Description}" TextWrapping="Wrap"  />

                <!--<Label 
                       Content="{Binding Message}" 
                       FontWeight="Bold" 
                       ToolTip="{Binding Description}" />-->
                
            </StackPanel>
        </DataTemplate>
        
    </my1:RibbonWindow.Resources>
    
        <Grid>
            
        <Grid.RowDefinitions>
            <RowDefinition Height="150" />
            <RowDefinition />
        </Grid.RowDefinitions>


        <my1:Ribbon SelectedTabChanged="Ribbon_SelectedTabChanged">

            <my1:Ribbon.ContextualGroups>
                <my1:RibbonContextualTabGroup Header="Editing" Visibility="Visible" x:Name="toolsGroupConfiguration" Background="Green" BorderBrush="Green" />
                <!--<my1:RibbonContextualTabGroup Header="Ergonomy" Visibility="Visible" x:Name="toolsGroupErgo" Background="Blue" BorderBrush="Blue" />-->
            </my1:Ribbon.ContextualGroups>

            <my1:RibbonTabItem Header="Configuration" Name="ConfigurationRibbonTabItem" Group="{Binding ElementName=toolsGroupConfiguration}">

                <my1:RibbonGroupBox Header="">

                    <!--To use ScreenTip you have to create it and set to ToolTip property-->
                    <my1:Button 
                        Name="buttonsave" 
                        Header="Save" 
                        Command="Save"
                        CommandTarget="{Binding Uc}"
                        LargeIcon="/ConfigEditor;component/Images/Sauve.png" 
                        Icon="/ConfigEditor;component/Images/Sauve.png" >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Save"
                                  HelpTopic="Save configuration"
                                  Text="Save the configuration."/>
                        </my1:Button.ToolTip>
                    </my1:Button>
                    
                </my1:RibbonGroupBox>


                <my1:RibbonGroupBox Header="Edit" >

                    <!--To use ScreenTip you have to create it and set to ToolTip property-->
                    <my1:Button 
                        Name="buttonUndo" 
                        Header="Undo" 
                        LargeIcon="/ConfigEditor;component/Images/Undo.png" 
                        Icon="/ConfigEditor;component/Images/Undo.png" 
                        Command="Undo"
                        CommandTarget="{Binding Uc}"
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Undo"
                                  HelpTopic="Undo last action"
                                  Text="Undo the last action executed."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                    <my1:Button 
                        Name="buttonRedo" 
                        Header="Redo" 
                        LargeIcon="/ConfigEditor;component/Images/Redo.png" 
                        Icon="/ConfigEditor;component/Images/Redo.png" 
                        Command="Redo"
                        CommandTarget="{Binding Uc}"
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Redo the last Action"
                                  HelpTopic="Redo the last Action"
                                  Text="Redo the last canceled action"/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                </my1:RibbonGroupBox>



                <my1:RibbonGroupBox Header="Clipboard" >

                    <!--To use ScreenTip you have to create it and set to ToolTip property-->
                    <!--<my1:Button 
                        Name="buttonCut" 
                        Header="Cut" 
                        LargeIcon="/ConfigEditor;component/Images/couper.png" 
                        Icon="/ConfigEditor;component/Images/couper.png" 
                        Command="Cut"
                        CommandTarget="{Binding Uc}"
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Cut"
                                  HelpTopic="cut the section"
                                  Text="Cut the selected section."/>
                        </my1:Button.ToolTip>
                    </my1:Button>-->

                    <my1:Button 
                        Name="buttonCopy" 
                        Header="Copy" 
                        LargeIcon="/ConfigEditor;component/Images/copier.png" 
                        Icon="/ConfigEditor;component/Images/copier.png" 
                        Command="Copy"
                        CommandTarget="{Binding Uc}"
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Copy the selected section"
                                  HelpTopic="Copy"
                                  Text="Copy the selected section"/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                    <my1:Button 
                        Name="buttonPaste" 
                        Header="Paste" 
                        LargeIcon="/ConfigEditor;component/Images/coller.png" 
                        Icon="/ConfigEditor;component/Images/coller.png" 
                        Command="Paste"
                        CommandTarget="{Binding Uc}"
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Paste the clipboard"
                                  HelpTopic="Paste"
                                  Text="Paste the clipboard"/>
                        </my1:Button.ToolTip>
                    </my1:Button>
                    
                </my1:RibbonGroupBox>
                

                <my1:RibbonGroupBox Header="Sections" >                    
                    <my1:Button 
                        Name="buttonAdd" 
                        Header="Add" 
                        LargeIcon="/ConfigEditor;component/Images/pluginAdd.png" 
                        Icon="/ConfigEditor;component/Images/pluginAdd.png" 
                        Command="u:UCConfigEditCommands.AddSection"
                        CommandTarget="{Binding Uc}" 
                        >
                    <my1:Button.ToolTip>
                        <my1:ScreenTip Title="Add section"
                                  HelpTopic="New section"
                                  Text="Add a new section configuration."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                    <my1:Button 
                        Name="buttonDel"
                        Header="Del" 
                        LargeIcon="/ConfigEditor;component/Images/pluginDel.png" 
                        Icon="/ConfigEditor;component/Images/pluginDel.png" 
                        Command="u:UCConfigEditCommands.DelSection"
                        CommandTarget="{Binding Uc}" >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Delete section"
                                  HelpTopic="delete section"
                                  Text="Delete the selected section configuration."/>
                        </my1:Button.ToolTip>
                    </my1:Button>
                </my1:RibbonGroupBox>

                
                <my1:RibbonGroupBox Header="Items" >

                    <!--To use ScreenTip you have to create it and set to ToolTip property-->
                    <my1:Button 
                        Name="buttonAddItem" 
                        Header="Add" 
                        LargeIcon="/ConfigEditor;component/Images/SectionAdd.png" 
                        Icon="/ConfigEditor;component/Images/SectionAdd.png" 
                        Command="u:UCConfigEditCommands.AddItem"
                        CommandTarget="{Binding Uc}" 
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Add section"
                                  HelpTopic="New section"
                                  Text="Add a new section configuration."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                    <my1:Button 
                        Name="buttonDelItem"
                        Header="Del" 
                        LargeIcon="/ConfigEditor;component/Images/SectionDel.png" 
                        Icon="/ConfigEditor;component/Images/SectionDel.png" 
                        Command="u:UCConfigEditCommands.DelItem"
                        CommandTarget="{Binding Uc}" 
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Delete section"
                                  HelpTopic="delete section"
                                  Text="Delete the selected section configuration."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                    <my1:Button 
                        Name="buttonEditItem" 
                        Header="Edit" 
                        LargeIcon="/ConfigEditor;component/Images/Editer.png" 
                        Icon="/ConfigEditor;component/Images/Editer.png" 
                        Command="u:UCConfigEditCommands.EditItem"
                        CommandTarget="{Binding Uc}" 
                        >
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Edit"
                                  HelpTopic="Edit property"
                                  Text="Edit the property in the template."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                </my1:RibbonGroupBox>

                <my1:RibbonGroupBox Header="Tools" >

                    <my1:Button 
                        Name="buttonMergeConfig" 
                        Header="Merge" 
                        LargeIcon="/ConfigEditor;component/Images/dossiervert.png" 
                        Icon="/ConfigEditor;component/Images/dossiervert.png" 
                        Command="u:UCConfigEditCommands.Merge"
                        CommandTarget="{Binding Uc}" Size="Large">
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Merge the split config file."
                                  HelpTopic="MergeConfig"
                                  Text="This section is located in child config file."/>
                        </my1:Button.ToolTip>
                    </my1:Button>

                </my1:RibbonGroupBox>

            </my1:RibbonTabItem>

            <my1:RibbonTabItem Header="Diagnostic" Name="DiagnosticConfigurationRibbonTabItem" >
                
                <my1:RibbonGroupBox Header="" >
                    <!--To use ScreenTip you have to create it and set to ToolTip property-->
                    
                    <!--<my1:Button Name="ShowInherit" 
                                Header="Hide" 
                                LargeIcon="/ConfigEditor;component/Images/Home.png" 
                                Icon="/ConfigEditor;component/Images/Home.png" 
                                Click="ShowInherits">
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Show / Hide Inherited items"
                                  HelpTopic="Show / Hide Inherited items"
                                  
                                  Text="Show / Hide Inherited items. &#x0a;"/>
                        </my1:Button.ToolTip>
                    </my1:Button>-->

                    <my1:SplitButton
       
                            Name="buttonCheckConfig" 
                            Header=" Check " 
                            LargeIcon="/ConfigEditor;component/Images/Check.png" 
                            Icon="/ConfigEditor;component/Images/Check.png" 
                            Command="p:Commands.Check"
                            CommandTarget="{Binding .}" >

                        <my1:Gallery Orientation="Vertical" ItemsSource="{Binding ElementName=Uc, Path=ListeValidators}">
                            <my1:Gallery.ItemTemplate>
                                <DataTemplate>
                                    <my1:GalleryItem>
                                        <my1:CheckBox Header="{Binding Header}" Tag="{Binding .}" IsChecked="{Binding IsChecked}" />
                                    </my1:GalleryItem>
                                </DataTemplate>
                            </my1:Gallery.ItemTemplate>
                        </my1:Gallery>

                    </my1:SplitButton>

                    <my1:Button Name="Clear1" 
                                Header="Clear" 
                                LargeIcon="/ConfigEditor;component/Images/Delete.png" 
                                Icon="/ConfigEditor;component/Images/Delete.png" 
                                Command="p:Commands.ClearOutput"
                        CommandTarget="{Binding .}">
                        
                        <my1:Button.ToolTip>
                            <my1:ScreenTip Title="Clear the diagnostic"
                                  HelpTopic="Clear the diagnostic"
                                  Text="Clear the diagnostic"/>
                        </my1:Button.ToolTip>
                        
                    </my1:Button>



                </my1:RibbonGroupBox>

            </my1:RibbonTabItem>

            <my1:Ribbon.Menu>
                
                <my1:Backstage Header="File" Background="Green" >
                    <my1:BackstageTabControl>

                        <my1:BackstageTabItem Header="Open" >
                            <Grid Margin="30" Width="520" HorizontalAlignment="Left">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>

                                
                                <Grid Grid.Row="0" Margin="0,0,6,0">
                                    
                                    <Button 
                                        Content="  Open configuration file  " 
                                        HorizontalAlignment="Left"  
                                        IsEnabled="True" 
                                        Command="Open"
                                        CommandTarget="{Binding Uc}"
                                        />
                                    
                                </Grid>

                                <Grid Grid.Row="1" Margin="0,0,20,0" DataContext="{Binding ElementName=Uc, Path=RecentFiles}">

                                    <Label Content="Recents files" Margin="0,8,15,0" FontSize="15" />

                                    <ItemsControl ItemsSource="{Binding .}" Margin="0,35,0,0" x:Name="ListeRecents" HorizontalAlignment="Stretch" >
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <StackPanel Orientation="Vertical" />
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Vertical" Margin="15,5,20,5" HorizontalAlignment="Stretch">

                                                    <Button Margin="5" Content="Test" Cursor="Hand" Tag="{Binding .}" Click="Button_OpenRecentFile">
                                                        <Button.Template>
                                                            <ControlTemplate TargetType="Button">
                                                                <TextBlock HorizontalAlignment="Left" TextDecorations="Underline" Text="{Binding FullName}"  ToolTip="{Binding FullName}">
                                                                    <ContentPresenter />
                                                                </TextBlock>
                                                            </ControlTemplate>
                                                        </Button.Template>
                                                        <Button.Style>
                                                            <Style TargetType="Button">
                                                                <Setter Property="Foreground" Value="Blue" />
                                                                <Style.Triggers>
                                                                    <Trigger Property="IsMouseOver" Value="true">
                                                                        <Setter Property="Foreground" Value="Red" />
                                                                    </Trigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Button.Style>
                                                    </Button>
                                                   
                                                </StackPanel>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>

                                </Grid>

                            </Grid>
                        </my1:BackstageTabItem>
                        
                        <my1:BackstageTabItem Header="Save">
                            <Grid Margin="30" Width="520" HorizontalAlignment="Left">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="60" />
                                    <RowDefinition Height="80" />
                                    <RowDefinition Height="80"/>
                                    <RowDefinition Height="80"/>
                                    <RowDefinition Height="80"/>
                                    <RowDefinition Height="30"/>
                                </Grid.RowDefinitions>

                                <Label Content="Choose the records mode." Height="28" HorizontalAlignment="Left" Margin="14,13,0,0" Name="label1" VerticalAlignment="Top" Width="322" />

                                <Grid Grid.Row="1" Margin="0,0,6,0">
                                    <RadioButton Content="Full" HorizontalAlignment="Left"  Name="radioSaveFull" VerticalAlignment="Top" IsThreeState="True" FontSize="15" FontWeight="Bold" GroupName="ModeSave" Checked="CheckModeSave" Unchecked="UnCheckModeSave" />
                                    <TextBlock Height="50" HorizontalAlignment="Left" Margin="14,19,0,0" Name="textBlock2" Text="TextCauses all properties to be written to the configuration file. This is useful mostly for creating information configuration files or moving configuration values from one machine to another." VerticalAlignment="Top" Width="485" TextWrapping="WrapWithOverflow" TextAlignment="Justify" />
                                </Grid>

                                <Grid Grid.Row="2" Margin="0,0,6,0">
                                    <RadioButton Content="Modified" HorizontalAlignment="Left"  Name="radioSaveModified" VerticalAlignment="Top" IsThreeState="True" FontSize="15" FontWeight="Bold" GroupName="ModeSave" IsChecked="True" Checked="CheckModeSave" Unchecked="UnCheckModeSave" />
                                    <TextBlock Height="47" HorizontalAlignment="Left" Margin="14,19,0,0" Name="textBlock1" Text="Causes only modified properties to be written to the configuration file, even when the value is the same as the inherited value." VerticalAlignment="Top" TextWrapping="WrapWithOverflow" Width="485" TextTrimming="None" TextAlignment="Justify" />
                                </Grid>

                                <Grid Grid.Row="3" Margin="0,0,6,0">
                                    <RadioButton Content="Minimum" HorizontalAlignment="Left"  Name="radioSaveMinimum" VerticalAlignment="Top" IsThreeState="True" FontSize="15" FontWeight="Bold" GroupName="ModeSave" Checked="CheckModeSave" Unchecked="UnCheckModeSave" />
                                    <TextBlock Height="52" HorizontalAlignment="Left" Margin="14,20,0,0" Name="textBlock3" Text="Causes only properties that differ from inherited values to be written to the configuration file." VerticalAlignment="Top" Width="485" TextWrapping="WrapWithOverflow" TextAlignment="Justify" />
                                </Grid>

                                <Grid Grid.Row="4" Margin="0,0,6,0">
                                    <CheckBox Content="Force save" HorizontalAlignment="Left"  Name="ForceSave" VerticalAlignment="Top" IsThreeState="True" FontSize="15" FontWeight="Bold" Checked="CheckModeSave" Unchecked="UnCheckModeSave" />
                                    <Label Content="Force save even if the file was not modified." Margin="0,17,0,0" />
                                </Grid>

                                <Grid Grid.Row="5" Margin="0,0,6,0">
                                    <Button 
                                        Content="  Save the configuration  " 
                                        HorizontalAlignment="Right"  
                                        IsEnabled="{Binding ElementName=Uc, Path=IsModified}" 
                                        Command="Save"
                                        CommandTarget="{Binding Uc}"
                                        />
                                </Grid>
                            
                            </Grid>
                        </my1:BackstageTabItem>

                        <my1:BackstageTabItem Header="Properties" DataContext="{Binding ElementName=Uc, Path=ListeProperties}">
                            
                            <Grid Margin="20">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="40" />
                                    <RowDefinition Height="200" />
                                    <RowDefinition  Height="*" />
                                </Grid.RowDefinitions>

                                <Label Content="List of Directories used for resolve the assemblies needed" />

                                <ListBox Grid.Row="1" ItemsSource="{Binding Directories}" Margin="0,20,20,20">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Grid Margin="2">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>
                                                <Button Tag="{Binding . }" Content="Remove" Click="RemoveDirectory" />
                                                <Label Grid.Column="1" Content="{Binding . }" />
                                            </Grid>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>

                            </Grid>
                           
                        </my1:BackstageTabItem>

                        <my1:BackstageTabItem Header="Close file" />
                            
                    </my1:BackstageTabControl>
                </my1:Backstage>
            
            </my1:Ribbon.Menu>
        
        </my1:Ribbon>

            
        <my:UCConfigEdit 
                x:Name="Uc" 
                Grid.Row="1" />

        <ScrollViewer x:Name="ContainerStatutList" Grid.Row="1" HorizontalScrollBarVisibility="Auto">
            <ItemsControl Visibility="Visible" x:Name="StatutList" HorizontalAlignment="Stretch" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <ContentPresenter Content="{Binding .}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        

    </Grid>

</my1:RibbonWindow>
